﻿using LCS.Api.Dtos;
using LCS.Api.Dtos.Login;
using LCS.Api.Localization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace LCS.Api.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    [Route("api/account")]
    [ApiController]
    public class AccountController : ApiBaseController
    {
        /// <summary>
        /// 
        /// </summary>
        public ILocalization _localization;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="localization"></param>
        public AccountController(ILocalization localization)
        {
            this._localization = localization;
        }


        /// <summary>
        /// 登录的接口
        /// </summary>
        /// <param name="input">输入用户名密码</param>
        /// <returns>是否登录成功</returns>
        [HttpPost]
        [Route("login")]
        public LoginOutputDto Login(LoginInputDto input)
        {
            if ((input.UserName == "admin") && (input.UserPassword == "admin"))
            {
                return new LoginOutputDto()
                {
                    Success = true,
                    Code = ResultCode.Success,
                    Message = this._localization.GetText("login_login_success")
                };
            }
            else
            {
                return new LoginOutputDto()
                {
                    Success = true,
                    Code = ResultCode.UserNameOrUserPasswordWrong,
                    Message = this._localization.GetText("login_login_failed")
                };

            }

        }


    }
}
